﻿using System.Linq;

namespace OpenWaves.ActivityFeed.Web
{
    public class GlobalActivityFeedBuilder: ActivityFeedBuilder
    {
        public GlobalActivityFeedBuilder(IActivityFeedService activityFeedService, IUpdateDtoBuilder updateDtoBuilder)
            : base(activityFeedService, updateDtoBuilder)
        {
        }

        protected override IQueryable<Update> FilterUpdates(IQueryable<Update> updates)
        {
            return updates;
        }

        protected override IQueryable<Update> SecurityTrimUpdates(IQueryable<Update> updates)
        {
            return updates.Where(u => u.IsPublic || u.UserGroups.Any(ug => this.UserGroups.Contains(ug)));
        }
    }
}